from django.shortcuts import render
from rest_framework.generics import ListAPIView
from home.models import NavModel
from dingxiang.utils import constants
from home.serial import NavSerializer
from dingxiang.utils.views import CacheListAPIView


# Create your views here.

# 顶部导航视图
class NavHeaderView(CacheListAPIView):
    queryset = NavModel.objects.filter(is_show=True, is_deleted=False, position=constants.NAV_HEADER).order_by('id')[
               :constants.NAV_HEADER_SIZE]
    serializer_class = NavSerializer


# 底部导航视图
class NavFooterView(CacheListAPIView):
    queryset = NavModel.objects.filter(is_show=True, is_deleted=False, position=constants.NAV_FOOTER).order_by('id')[
               :constants.NAV_FOOTER_SIZE]
    serializer_class = NavSerializer
